<include file="Public:header" />
<script type="text/javascript" src="__PUBLIC__/style/js/TableFreeze.js"></script>

<style>
	table tbody tr{cursor:move;padding:0px;}
	.table thead>tr>th{padding:3px;}
	.table tbody>tr>td{padding:3px;}
</style>
<script>
$(function(){
	var scroll_width = 5;
	$("#table_div").height(window.innerHeight-$("#table_div").offset().top-10);
	$(window).resize(function(){
		$("#table_div").height(window.innerHeight-$("#table_div").offset().top-10);
		$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width-1).width($("#oTableLH_tab_Test3").width());
		$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width);
	})
	$("#tab_Test3").FrozenTable(1,0,0);
	$("#oDivL_tab_Test3").height($("#table_div").height()-scroll_width).width($("#oTableLH_tab_Test3").width());
	$("#oDivH_tab_Test3").height($("#oTableLH_tab_Test3").height()).width($("#table_div").width()-scroll_width);
})
</script>
<div class="wrapper wrapper-content ">
	<div class="row">
		<include file="Public:alert" />
		<div class="col-md-12">
			<include file="Setting:setting_left" />
			<div class="col-lg-10 ">
				<div class="table-content" style="padding-bottom:10px">
					<div class="ibox-content mar-top" style="border-bottom:none;padding-top:20px;">
						<div class="bulk-actions align-left">
							<button onclick="del_status(this)" style="background:#fff;border:1px solid #e3e3e3;color:#000;" type="button" class="btn btn-primary" >&nbsp;{:L('DELETE')}</button>
							<div class="pull-right">
								<a class="btn btn-primary" id="add">添加{$field_name}类型</a>
							</div>
						</div> 
					</div>
					<form action="" id="form1" method="post">
						<div class="col-sm-12 ibox-content" style="margin-top:0px;padding:0px;">
							<div class="full-height-scroll" id="table_div" style="left:0px;top:0px;">
								<table class="table table-hover table-striped table_thead_fixed" id="tab_Test3" >
									<notempty name="type_list">
									<thead>
										<tr class="tabTh">
											<td style="width:50px;text-align:center;">
												<div class="checkbox checkbox-primary">
													<input type="checkbox" class="check_all"/>
													<label for=""></label>
												</div>
											</td>
											<td>名称</td>
											<td>创建时间</td>
											<td>操作</td>
										</tr>
									</thead>
									<tbody>
										<volist name="type_list" id="vo">
											<tr>
												<td style="text-align:center;">
													<div class="checkbox checkbox-primary">
														<input name="id[]" class="check_list" type="checkbox" value="{$vo['id']}"/>
														<label for=""></label>
													</div>
												</td>
												<td>{$vo['name']}</td>
												<td>{$vo['create_time'|date='Y-m-d H:i:s',###]}</td>
												<td>
													<a class="edit" href="javascript:void(0)" rel="{$vo['id']}">{:L('EDIT')}</a>&nbsp;&nbsp;
												</td>
											</tr>
										</volist>
									</tbody>
									<else />
										<tr>
											<td><include file="Public:nodata" /></td>
										</tr>
									</notempty>
								</table>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="" style="display:none;" id="dialog-add" title="添加{$field_name}类型">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>
<div class="" style="display:none;" id="dialog-edit" title="编辑{$field_name}类型">
	<div class="spiner-example">
		<div class="sk-spinner sk-spinner-three-bounce">
			<div class="sk-bounce1"></div>
			<div class="sk-bounce2"></div>
			<div class="sk-bounce3"></div>
		</div>
	</div>
</div>

<script type="text/javascript">	
$("#dialog-add").dialog({
	autoOpen: false,
	modal: true,
	width: 450,
	maxHeight: 450,
	position: ["center",100],
	close:function(){
		$(this).html("");
	},
	buttons: {
		"确定": function () {
			$('#status_form1').submit();
			$(this).dialog("close");
		},
		"取消": function () {
			$(this).dialog("close");
		}
	}
});

$("#dialog-edit").dialog({
	autoOpen: false,
	modal: true,
	width: 450,
	maxHeight: 450,
	position: ["center",100],
	close:function(){
		$(this).html("");
	},
	buttons: {
		"确定": function () {
			$('#status_form2').submit();
			$(this).dialog("close");
		},
		"取消": function () {
			$(this).dialog("close");
		}
	}
});

$(function(){
	$("#check_all").click(function(){
		$("input[class='list']").prop('checked', $(this).prop("checked"));
	});

	$("#add").click(function(){
		var field = "{$_GET['field']}";
		$('#dialog-add').dialog('open');
		$('#dialog-add').load('{:U("setting/financeadd","field=")}'+field);
	});

	$(".edit").click(function(){
		var id = $(this).attr('rel');
		$('#dialog-edit').dialog('open');
		$('#dialog-edit').load('{:U("setting/financeedit","id=")}'+id);
	});
});

function del_status(obj){
	var field_name = "{$field_name}";
	var id_array = new Array();
	$("input.check_list:checked").each(function(){  
		id_array.push($(this).val());
	});
	if(id_array.length == 0){
		swal({
			title: "温馨提示",
			text: "请先选择要删除的"+field_name+"类型!",
			type: "warning"
		})
		return false;
	}else{
		swal({
			title: "您确定要删除该"+field_name+"类型吗？",
   			text: "删除后将无法恢复，请谨慎操作！",
			type: "warning",   
			showCancelButton: true,   
			confirmButtonColor: "#DD6B55",   
			confirmButtonText: "是的，我要删除！",
	        cancelButtonText:'让我再考虑一下…',
	        closeOnConfirm:false,
	        closeOnCancel:false
		},
		function(isConfirm){
	        if (isConfirm) {
				$.ajax({
					type: "POST",
					url: "{:U('setting/financedel')}",
					data: $("#form1").serialize(),
					async: true,
					success: function(data) {
						if(data.status == 1){
							swal({
								title: "删除成功！",
								text: "即将刷新页面!",
								type: "success"
							});
							location.reload();
						}else{
							 swal({
								title: "操作失败!",
								text: data.info,
								type: "error"
							});
						}
					}
				});
			} else {
	            swal("已取消","您取消了删除操作！","error");
	        }
	    });
	}
}
</script>
<include file="Public:footer" />